<template>
	<div>
		<view v-for="(item,index) in brightness" :key="index">
			<button type="default" size="mini" @click="setliang">设置亮度{{item}}</button>
		</view>
		<view style="margin-top: 160rpx;">获取屏幕亮度：{{BrightnessNuM}}</view>
		<view><button type="default" size="mini" @click="getBrightness">获取屏幕亮度</button></view>

		<view style="margin-top: 100rpx;"><button type="default" size="mini" @click="setBrightness">设置是否保持常亮状态</button>
		</view>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				brightness: [0.2, 0.4, 0.6, 0.8, 1],
				BrightnessNuM: null
			}
		},
		methods: {
			setliang(num) {
				uni.setScreenBrightness({
					value: num,
					success: function() {
						console.log('success');
					}
				});
			},
			getBrightness() {
				let _this = this;
				uni.getScreenBrightness({
					success: function(res) {
						console.log('屏幕亮度值：' + res.value);
						_this.BrightnessNuM = res.value
					}
				});
			},
			setBrightness() {
				uni.setKeepScreenOn({
					keepScreenOn: true
				});
			}
		}
	}
</script>

<style scoped>

</style>
